package com.woniuxy.service.impl;

import com.woniuxy.dao.ManagerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.lang.annotation.Documented;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Transactional
public class Impl {
    @Autowired(required = false)
    private ManagerDao managerDao;

    public ManagerDao getManagerDao() {
        return managerDao;
    }

    /*@Transactional*/
    public void addOne(){
        Map<String, String> map = new HashMap<>();
        map.put("account","zhangsan");
        map.put("password","123456");
        map.put("role_id","1");


        //这句话之前是成功的
//        Map<String, String> one = managerDao.getOne(1255);
        map.put("status","1");
        //下面的add方法就要报错
        int i = managerDao.addOne(map);
        //如果没有事务，这个插入是成功的不会回滚。
        if (i>0){
            System.out.println("新增成功");
        }else{
            System.out.println("执行失败");
        }

    }
    public  Map getOne(int id) {
        System.out.println("impl正常");
        Map<String, String> one = getManagerDao().getOne(id);
        return one;
    }

    public List<Map<String, String>> findAllOne() {
        System.out.println("findAllOne");
        return null;
    }

    public int deleteOne(int id) {
        System.out.println("deleteOne,现在获取到的id是多少："+id);
        return 000;
    }
}

